from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

chrome_driver=webdriver.Chrome()
chrome_driver.maximize_window()

chrome_driver.get('https://www.4399.com/')


def login_with_single_id():


    WebDriverWait(chrome_driver, 5).until(EC.element_to_be_clickable((By.ID, "login_tologin")))
login_control = chrome_driver.find_element(By.ID, "login_tologin")
login_control.click()
WebDriverWait(chrome_driver, 15).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="username"]')))
id_control = chrome_driver.find_element(By.XPATH, '//*[@id="username"]')
WebDriverWait(chrome_driver, 15).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="j-password"]')))
pwd_control = chrome_driver.find_element(By.XPATH, '//*[@id="j-password"]')
id_control.send_keys('3178071914')
pwd_control.send_keys('zzh20040608')
WebDriverWait(chrome_driver, 15).until(
    EC.element_to_be_clickable((By.XPATH, '//*[@id="login_form"]/fieldset/div[5]/input')))
login_button_control = chrome_driver.find_element((By.XPATH, '//*[@id="login_form"]/fieldset/div[5]/input'))
login_button_control.click()
